OpenStack Havana - Add Virtual Machine Images
2013/12/23 |
Add Virtual Machine images in Glance.
|
|
[1] | Load environment variables first. |
[root@dlp ~]# unset SERVICE_TOKEN [root@dlp ~]# unset SERVICE_ENDPOINT
[root@dlp ~]#
vi ~/keystonerc
export OS_USERNAME=admin
export OS_PASSWORD=adminpassword export OS_TENANT_NAME=admin export OS_AUTH_URL=http://10.0.0.30:35357/v2.0/ export PS1='[\u@\h \W(keystone)]\$ '
[root@dlp ~]#
chmod 600 ~/keystonerc [root@dlp ~]# source ~/keystonerc [root@dlp ~(keystone)]# echo "source ~/keystonerc " >> ~/.bash_profile
# confirm status (it's OK if no errors are shown) [root@dlp ~(keystone)]# glance image-list
|
[2] | For example, Create a Virtual Machine image of Fedora 20 for adding. |
# create a disk image [root@dlp ~]# qemu-img create -f qcow2 /var/kvm/images/fedora20.img 10G
# install [root@dlp ~]# virt-install \
Starting install...
-n fedora20 \ -r 2048 \ --disk path=/var/kvm/images/fedora20.img,format=qcow2 \ --vcpus=2 \ --os-type linux \ --os-variant=fedora20 \ --nographics \ --console pty,target_type=serial \ --location='http://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/20/Fedora/x86_64/os/' \ --extra-args='console=ttyS0,115200n8 serial' # installation start |
[3] |
After installation, change settings in virtual machine like follows and shutdown it.
* delete or comment out the line "HWADDR" and "UUID" in /etc/sysconfig/network-scripts/ifcfg-eth0 * set "dhcp" for "BOOTPROTO" in /etc/sysconfig/network-scripts/ifcfg-eth0 * delete the file "/etc/udev/rules.d/70-persistent-net.rules" |
[4] | Add the virtual image to Glance. |
[root@dlp ~(keystone)]# glance image-create --name="Fedora20" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/fedora20.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 04bfefea7979b32a9811e34451cf1084 | | container_format | bare | | created_at | 2013-12-26T03:54:54 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | f30308e3-736e-42b4-807f-8b56d4a3d7e9 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | Fedora20 | | owner | fd861362f7b84b80a639e9010703dbce | | protected | False | | size | 1355415552 | | status | active | | updated_at | 2013-12-26T03:55:19 | +------------------+--------------------------------------+[root@dlp ~(keystone)]# glance image-list +------------+----------+-------------+------------------+------------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +------------+----------+-------------+------------------+------------+--------+ | f30308e3-7 | Fedora20 | qcow2 | bare | 1355415552 | active | +------------+----------+-------------+------------------+------------+--------+ |
[5] | By the way, if you got an image fron internet, it's OK to simplt add it like follows. |
[root@dlp ~]#
[root@dlp ~]# wget http://cloud-images.ubuntu.com/releases/13.10/release/ubuntu-13.10-server-cloudimg-amd64-disk1.img -P /var/kvm/images
glance image-create --name="Ubuntu1310" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/ubuntu-13.10-server-cloudimg-amd64-disk1.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 0592d5276a508fac4606af4f198b2bbc | | container_format | bare | | created_at | 2013-12-20T07:32:15 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | ccb4561a-218a-4ef5-93d1-0fe986a0c41e | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu1310 | | owner | 28799bf2e54e4b23b59a55305af3f1b5 | | protected | False | | size | 243269632 | | status | active | | updated_at | 2013-12-20T07:32:21 | +------------------+--------------------------------------+ |